# include <bits/stdc++.h>
using namespace std;

//翻转部分单链表
struct list_node {
    int val;
    struct list_node * next;
};

list_node * input_list(void)
{
    int n, val;
    list_node * phead = new list_node();
    list_node * cur_pnode = phead;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &val);
        if (i == 1) {
            cur_pnode->val = val;
            cur_pnode->next = NULL;
        }
        else {
            list_node * new_pnode = new list_node();
            new_pnode->val = val;
            new_pnode->next = NULL;
            cur_pnode->next = new_pnode;
            cur_pnode = new_pnode;
        }
    }
    return phead;
}

list_node * reverse_list(list_node * head, int L, int R)
{
    list_node* del = new list_node;
    list_node* guard = del;
    guard->next = head;
    
    list_node* prev = guard;
    list_node* cur = head;
    list_node* next = nullptr;
    
    for (int i = 1; i<L; ++i)
    {
        prev = cur;
        cur = cur->next;
    }
    guard = prev;
    
    for (int i = L; i<=R; ++i) 
    {
        next = cur->next;
        cur->next = prev;
        prev = cur;
        cur = next;
    }
    guard->next->next = cur;
    guard->next = prev;
    
    guard = del->next;
    delete del;
    return guard;
}

void print_list(list_node * head)
{
    while (head != NULL) {
        printf("%d ", head->val);
        head = head->next;
    }
    puts("");
}


int main ()
{
    int L, R;
    list_node * head = input_list();
    scanf("%d%d", &L, &R);
    list_node * new_head = reverse_list(head, L, R);
    print_list(new_head);
    return 0;
}